/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
 * Licensed under Simplified BSD License
 *
 *
 * @author: jin Chen 
 * @date: Mar 8, 2005$
 * @version: 1.0
 */
package edu.psu.geovista.app.pcp.plot.control.tools;

import edu.psu.geovista.app.pcp.toolkits.group.DataIDGroup;
import edu.psu.geovista.app.pcp.toolkits.group.DataIDSet;
import edu.psu.geovista.classification.CategoryItf;

import java.util.HashSet;

public abstract class BasicDModeActor implements DataModeActor{
     private DataIDGroup grpData; //// 
     private  DataSelectTool datatool;

    protected BasicDModeActor(DataSelectTool datatool) {
        this.datatool = datatool;
    }
     
    /**
     * common procedure
     */
    public void updateOnSwitchMode() {
         final DataSelectTool tool = this.getTool();
         tool.clearSelection();
         //tool.setStopActOnMouse(false);
    }

     public DataSelectTool getTool() {
        return datatool;
    }
    public void setGrpData(DataIDGroup selectionGrpData) {
            this.grpData = selectionGrpData;

    }

    public DataIDGroup getGrpData() {
        return grpData;
    }

     /**
         *  
         * @param ctgs
         */
        public void updateCtgMemberIds(CategoryItf[] ctgs){
            DataIDGroup grp=new DataIDGroup();
            for (int i=0;i<ctgs.length  ;i++){
                CategoryItf ctg=ctgs[i];
                DataIDSet idSet=new DataIDSet((HashSet)ctg.getMemberIds().clone() );
                idSet.setId(Integer.toString(i) ) ;
                grp.add(idSet);
            }

            setGrpData(grp);

        }
}
